package com.huchao.www.controller;

import com.huchao.www.service.api.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description:
 * @BelongsProject: springMVC
 * @BelongsPackage: com.huchao.www.controller
 * @Author: 亖思
 * @CreateTime: 2022/11/20 9:43
 * @Version: 1.0
 */

@Controller
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private AdminService adminService;

    @GetMapping("/index")
    public String index(HttpServletRequest request, Model model){
        if(!request.getSession().getAttribute("username").equals("")){
            String username = request.getSession().getAttribute("username").toString();
            model.addAttribute("loginUser",adminService.findByUserName(username));
        }
        return "html/index";
    }

    @GetMapping("/admin-list")
    public String adminList(){
        return "html/admin-list";
    }
}
